/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ensisa.sunspot;

/**
 *
 * @author michel
 */
public class Logger {

    static private Logger logger = new Logger ();
    static private boolean infoSilent=false;
    static private boolean debugSilent=false;

    static public boolean isInfoSilent () {
        return infoSilent;
    }

    static public void setInfoSilent (boolean s) {
        infoSilent = s;
    }

    static public boolean isDebugSilent () {
        return debugSilent;
    }

    static public void setDebugSilent (boolean s) {
        debugSilent = s;
    }

    static public Logger getLogger() {
        return logger;
    }

    private void print (String text) {
        System.err.print(text);
    }

    private void println () {
        System.err.println ();
    }

    private void println(String module, String subModule, Object text) {
        print (module);
        print (" : ");
        if (subModule != null) {
            print (subModule);
            if (text != null) {
                print ("=");
                print (text.toString());
            } else {
                print ("= null");
            }
        } else {
            if (text != null) {
                print (text.toString());
            } else {
                print ("= null");
            }
        }
        println ();
    }

    public void infoln(String module, String subModule, long value) {
        if (isInfoSilent()) return;
        println (module, subModule, Long.toString(value));
    }

    public void infoln(String module, String subModule, double value) {
        if (isInfoSilent()) return;
        println (module, subModule, Double.toString(value));
    }

    public void infoln(String module, String subModule, Object object) {
        if (isInfoSilent()) return;
        println (module, subModule, object);
    }

    public void debugln(String module, String subModule, long value) {
        if (isDebugSilent()) return;
        println (module, subModule, Long.toString(value));
    }

    public void debugln(String module, String subModule, double value) {
        if (isDebugSilent()) return;
        println (module, subModule, Double.toString(value));
    }

    public void debugln(String module, String subModule, Object object) {
        if (isDebugSilent()) return;
        println (module, subModule, object);
    }
}
